package com.my.commonlib.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.my.commonlib.event.EventTypeFinishActivity;
import com.my.commonlib.event.EventTypeLoginOrLoginOut;


import de.greenrobot.event.EventBus;

/**
 */
public class BaseActivity extends AppCompatActivity implements View.OnClickListener{

    public Activity mActivity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        mActivity = this;
        EventBus.getDefault().register(this);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    public void initActionBar(){

    }

    public void onEvent(EventTypeLoginOrLoginOut event){

    }

    public void onEventMainThread(EventTypeFinishActivity event){
        if(event.getClassName().equals(mActivity.getClass().getSimpleName())){
            this.finish();
        }
    }

    @Override
    public void onClick(View v) {

    }

    /**
     * 隐藏系统状态条(电池,信号,wifi之类的)
     */
    public void hideSystemStatus(){
        int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        //获得当前窗体对象
        Window window = this.getWindow();
        //设置当前窗体为全屏显示
        window.setFlags(flag, flag);
    }
}
